package Connect;

import java.text.DecimalFormat;

public class ConnectionInfo {

	// Information required for opening a connection with the database.
	public static String myJDBCDriver() {
		return "com.mysql.jdbc.Driver";
	}

	public static String myURL() {
		return "jdbc:mysql://localhost/htah_database";
	}

	public static String myUserID() {
		return "root";
	}

	public static String myPassword() {
		return "789123";
	}

	// Rounding doubles to two decimal places.
	public static double twoSigFigs(double d) {
		DecimalFormat formatter = new DecimalFormat("#.##");
		return Double.valueOf(formatter.format(d));
	}

	// Converts double strings to double strings two decimals
	public static String s2D(String d) {
		int length = d.length();
		int index = d.indexOf('.');
		while (index > length - 3) {
			d += "0";
			length = d.length();
		}
		if (index < length - 3) {
			d = d.substring(0, index + 3);
		}

		return d;
	}
}
